<?php
require_once "../Common/database.php";

mysql_query("SELECT * FROM tblInventory WHERE Serial LIKE '$_POST[serial]' ORDER BY `key` DESC ");

if(mysql_affected_rows()=='0')
{
$result = mysql_query("SELECT * FROM tblInventory ORDER BY `key` DESC ");
$row = mysql_fetch_array($result);

#echo $row['key'];


#echo $row['key'];
$key=$row['key']+1;
#echo $key;
$query="INSERT INTO tblInventory VALUES ('$key','$_POST[branch]', '$_POST[department]', '$_POST[type]', '$_POST[serial]', '$_POST[checkedby]', '$_POST[date]', '$_POST[reason]', '$_POST[action]', '$_POST[faulty]', '$_POST[status]')";
mysql_query($query);
#echo $query ;
echo '<center><h1>Equipment Status Form </h1></center>';
echo '<h2 align=right> ID :  '.$key.'</h2>';
echo '<h2 align = left><br>Branch : '.$_POST[branch];
echo '<br><br>Department : '.$_POST[department];
echo '<br><br>Type of Equpment : '.$_POST[type];
echo '<br><br>Serial Number : '.$_POST[serial];
echo '<br><br>Checked by : '.$_POST[checkedby];
echo '<br><br>Date Checked : '.$_POST[date];
echo '<br><br><br>Reason : <br>'.$_POST[reason];
echo '<br><br><br>Action : <br>'.$_POST[action];
echo '<br><br>Faulty : '.$_POST[faulty];
echo '<br><br>Status : '.$_POST[status];
echo '</h2>';
echo '<p><a href="../index.php?m=i&p=iview">Back</a>';
echo '<center><font size=-5>Created by VHS</font>';

}
else
{
 $result = mysql_query("SELECT * FROM tblInventory WHERE Serial LIKE '$_POST[serial]' ORDER BY `key` DESC ");
$row = mysql_fetch_array($result);
 echo 'Not a unique Serial Number Conflicts with ID : <a href="../index.php?m=i&p=iupdate&f2='.$row['key'].'">'.$row['key'].'</a>';
echo '<p><a href="../index.php?m=i&p=iadd">Back</a>';
}

?>